<!DOCTYPE html>
<html>
    <head>
        <style type="text/css"> 
            #div1{
                width: 100px;
                height:100px;
                background-color:red;
                float:left;         /*给div1添加左浮动*/
                }
            #div2{
                width: 100px;
                height:100px;
                background-color:yellow;
                float:right;         /*给div2添加右浮动*/
                }
        </style>
    </head>
    <body>
        <div id="div1">元素向左浮动</div> 
        <div id="div2">元素向右浮动</div>
    </body>
</html>